<?php
include_once 'class/ProjectList.php';
include_once 'class/Project.php';
include_once 'class/Fase.php';
include_once 'class/FaseStap.php';
include_once 'class/ProjectFasering.php';

//include 'class/Persoon.php';
?>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>ProjectStatus</title>
    </head>
    <body>
        <?php
        // put your code here
        //$test = new TestProject();
        //$test2 = new TestPersoon();
        ?>
        <table>
            <tr><td>Person ID</td><td>Naam</td><td>Last Name</td><td>Persoon rol</td></tr>
            <?php
            $project_list = new ProjectList();
            $project_ids = $project_list->getProjectListIDs();
            
            
            //*
            echo __FILE__.__LINE__.__FUNCTION__.'<br />';
            echo '<pre>';
            var_dump($project_ids);
            echo '</pre>';
            //*/
            
            foreach( $project_ids as $idx => $id){
                $project_persoon = $project_list->getProjectPersonList($id);

                echo __FILE__. __LINE__.'<pre>';
                var_dump($project_list);
                var_dump($project_persoon);
                echo '</pre>';

                if ( !is_array($project_persoon)){
                    echo '<tr><td colspan="4">'." Geen personen lijst voor project id $id</td></tr>";

                    /**
                     * TODO: Oplossen met try catch.
                     */
                } else {
                    foreach( $project_persoon as $idx => $data_array ){

                        echo "<tr><td>".$data_array['person_id']."</td><td>".$data_array['person_name']."</td><td>".$data_array['person_fam_name']."</td><td>".$data_array['project_person_type_id']."</td></tr>";

                    }
                }

            } 
            ?>
        </table>
        <hr />
        <table>
            <tr><td>Project Id</td><td>Project Naam</td></tr>
            <?php
            
            $cnt = 0;
            while( $person_array = $project_list->getNextProject() ){
                
                $cnt++;
                echo "<tr><td>".$person_array['id']."</td><td>".$person_array['name']."</td></tr>";
            }
            if ( $cnt == 0){
                echo "<tr><td colspan='2'>No projects in DB</td></tr>";
            }
            ?>
        </table>
        
        <hr />
        
        <?php
        
            // Test fase opbouw lijstje.
            include_once 'class/db/dbFase.php';
            $testDbFase = new TestDbFase();
            
            $testFase = new TestFase();
        ?>
        </table>
        <hr />
        <table>
            <tr><td><strong>Stap Id</strong></td><td><strong>Fase stap naam</strong></td></tr>
            <?php
            $fase = new Fase(1);
            
            $cnt = 0;
            while( $step_array = $fase->getNextStep() ){
                
                
                /*
                echo __FILE__.__LINE__.__FUNCTION__.'<br />';
                echo '<pre>';
                var_dump($step_array);
                echo '</pre>';
                //*/
                
                $cnt++;
                echo "<tr><td>".$step_array['id']."</td><td>".$step_array['name']."</td></tr>";
            }
            if ( $cnt == 0){
                echo "<tr><td colspan='2'>No fase steps in DB</td></tr>";
            }
            ?>
        </table>
        
        <hr />
        <table>
            <tr><td><strong>Stap Id</strong></td><td><strong>Fase stap naam</strong></td></tr>
            <?php
            $fase = new Fase(1);
            
            $cnt = 0;
            while( $step_array = $fase->getNextStep() ){
                
                
                /*
                echo __FILE__.__LINE__.__FUNCTION__.'<br />';
                echo '<pre>';
                var_dump($step_array);
                echo '</pre>';
                //*/
                
                $cnt++;
                echo "<tr><td>".$step_array['id']."</td><td>".$step_array['name']."</td></tr>";
            }
            if ( $cnt == 0){
                echo "<tr><td colspan='2'>No fase steps in DB</td></tr>";
            }
            ?>
        </table>
        
        <hr />
        <?php
            $project_fasering = new TestProjectFasering();
            
            
            
            
        //*
        echo __FILE__.__LINE__.__FUNCTION__.'<br />';
        echo '<pre>';
        
        //echo '/**** TODO aantal fase stappen per fase getFaseStepCount($fasenr) ***/<br />';
        
        echo '/**** TODO alle fases van alle objecten na elkaar ***/<br />';
        echo '/**** TODO alle fasestappen voor alle fases ***/<br />';

        echo '</pre>';
        //*/
        echo '<pre>';
        //var_dump($test);
        echo '</pre>';
        ?>
        <hr />
        <strong> TEST CLEANUP SECTION</strong>
        
        
        <?php
        /**
         * 
         * Test the debug functionality
         * 
         */
        require_once 'class/Debug.php';
        $debug = new TestDebug();
        
        ?>
        
        </table>
    </body>
</html>
